package com.lxf.cloudorder.bean;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author 罗兴发
 * @data 2025/5/8 17:33
 * @description：订单实体类
 */
@Data
@Accessors(chain = true)  //链式结构
@NoArgsConstructor   //无参构造函数
@Document(indexName = "es") //创建的es库名称
public class OrderBean implements Serializable {
    private static final long serialVersionUID = 1L;//控制序列化版本兼容
    @Id
    @Field(type = FieldType.Keyword)
    private String orderCode;//订单流水号

    @Field(type = FieldType.Keyword)
    private String pCode;//商品编码

    @Field(type = FieldType.Text)
    private String goodName;//商品名称

    @Field(type = FieldType.Integer)
    private Integer userId;//下单用户

    @Field(type = FieldType.Integer)
    private Integer pNum;//下单数量

    @Field(type = FieldType.Integer)
    private Integer surplusNum;//剩余数量

    @Field(type = FieldType.Double)
    private BigDecimal unitPrice;//商品单价

    @Field(type = FieldType.Double)
    private BigDecimal totalPrice;//订单总价

    @Field(type = FieldType.Date, format = DateFormat.basic_date_time)
    private String addTime;//添加时间
}
